package com.stu.spring.sim.sample;

import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 简单的 AnnotationConfigApplicationContext 模拟
 */
@ComponentScan
@Configuration
@EnableTransactionManagement
public class SimpleAnnotationCtxMain {

    @Test
    public void mainTest() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SimpleAnnotationCtxMain.class);
        // 获取 Bean 并使用
        IHelloService bean = context.getBean(IHelloService.class);
        System.out.println(bean.hello());
        context.close();
    }

    public String hello(){
        return "hello";
    }

}
